package ar.edu.um.isa.mb.console;

import java.util.Calendar;
import java.util.List;

import ar.edu.um.isa.common.ServiceLocator;
import ar.edu.um.isa.facade.MicrobloggingFacade;
import ar.edu.um.isa.model.Publication;
import ar.edu.um.isa.model.Publisher;

public class Microblogging {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Publication publication = new Publication();
		Publisher publisher = new Publisher();
		publisher.setIdPublisher(1);
		publisher.setName("jere");
		publication.setPublisher(publisher);
		publication.setDate(Calendar.getInstance().getTime());
		publication.setContent("My second publication #second ");
		try {
			MicrobloggingFacade microbloggingFacade = (MicrobloggingFacade) ServiceLocator.getService("microbloggingFacade");
			microbloggingFacade.publish(publication);
			
			List<Publication> pub = microbloggingFacade.findPublicationByPublisher(publisher);
			
			for (Publication p : pub) {
				System.out.println(p.getIdPublication() + " - " + p.getPublisher().getIdPublisher() + " - " + p.getDate() + " - " + p.getContent());
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
